////////////////////////////////////////////////
//	File	:	"CObjectManager.h"
//
//	Author	:	David Brown (DB)
//
//	Purpose	:	To contain and manage all of our game objects.
/////////////////////////////////////////////////
#pragma once

#include "../tools/MathHelper.h"
#include "../headers/Base.h"
#include <map>
using namespace std;

class CBase;


	class CObjectManager
	{
	private:
		map<unsigned int, vector<CBase *>> m_vObjectList;
		map<unsigned int, vector<CBase *>> m_vObjectByType;
		vector<CBase *> m_vCollidableObjectList;
		vector<CBase *> m_vObstacleList;


		static CObjectManager * instance;

		CObjectManager(void);
		~CObjectManager(void);

		CObjectManager(const CObjectManager &) {};
		CObjectManager & operator=(const CObjectManager &) {};

		unsigned int m_uiIDCounter;

	public:

		static CObjectManager * GetInstance();
		void DeleteInstance();

		void UpdateObjects(float dt, bool getInput);
		void RenderObjects(vector2D vCamera);

		//Layer 0, Parallex Layer
		//Layer 1, Background Layer
		//Layer 2, Player Layer
		//Layer 3, Foreground Layer
		void AddObject(CBase* pObject, unsigned int layer);

		void RemoveObject(CBase* pObject, unsigned int layer);

		void RemoveAllObjects(void);

		void CheckCollision();

		CBase * GetObjectById(unsigned int id);


		//Returns a vector containing all the objects on a given
		//display layer
		vector<CBase *> & GetObjectsByLayer(unsigned int layer)
		{
			return m_vObjectList[layer];
		}

		//Returns a vector containing all the objects based on the 
		//Object Type, defined in CBase.h
		vector<CBase *> & GetObjectsByType(unsigned int type)
		{
			return m_vObjectByType[type];
		}

		//Returns a vector containing all the objects marked as 
		//obstacles
		vector<CBase *> & GetObstacles()
		{
			return m_vObstacleList;
		}

	};
